﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="NewIncomingTransmittal.aspx.cs"
    Inherits="POI.eTransmittal.WebApp.NewIncomingTransmittal" %>

<%@ Register Assembly="DevExpress.Web.v11.2, Version=11.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxSplitter" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.ASPxEditors.v11.2, Version=11.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxEditors" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.v11.2, Version=11.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxUploadControl" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.v11.2, Version=11.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxRoundPanel" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.v11.2, Version=11.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxPanel" TagPrefix="dx" %>
<%@ Register assembly="DevExpress.Web.v11.2, Version=11.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxCallback" tagprefix="dx" %>
<%@ Register assembly="DevExpress.Xpo.v11.2.Web, Version=11.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Xpo" tagprefix="dx" %>
<%@ Register assembly="DevExpress.Web.v11.2, Version=11.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxPopupControl" tagprefix="dx" %>
<%@ Register assembly="DevExpress.Web.ASPxGridView.v11.2, Version=11.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxGridView" tagprefix="dx" %>
<%@ Register assembly="DevExpress.Web.v11.2, Version=11.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxCallbackPanel" tagprefix="dx" %>
<%@ Register assembly="DevExpress.Web.v11.2, Version=11.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxHiddenField" tagprefix="dx" %>
<%@ Register assembly="DevExpress.Web.v11.2, Version=11.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxTabControl" tagprefix="dx" %>
<%@ Register src="Usercontrols/StatusControl.ascx" tagname="StatusControl" tagprefix="uc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Incoming transmittal registration</title>
   <script type="text/javascript">
       function OnDistributeEnd(e) {
           alert(e.toString());
       }

       function onContactSelected(s, e) {
           grdContact.GetRowValues(e.visibleIndex, 'Name;FaxNo', onGetContactValues);
      
       }
       function onGetContactValues(values) {
        
           bteFrom.SetText(values[0]);
           txtFaxFrom.SetText(values[1]);
           popContact.Hide();
       }
       var curFromText;
       var curFromFax;
       function AddContact() {
           curFromText = cboFrom.GetText();
           curFromFax = cboFaxFrom.GetText();
           clbPanlFrom.PerformCallback(cboFrom.GetText() + ';' + cboFaxFrom.GetText());
       
       }
       function ShowError(err) {
           alert(err);
       }
       function ShowMessage(mess) {
           cboFrom.SetText = curFromText;
           cboFromFax = curFromFax;
           alert(mess);
       }

       var txtctr;
       var lbUserId;
       var key;
  var contactSuccess = true;
  function ShowSelectEmployee(s, mode) {

      txtctr = s;
      key = mode;
    
   //  txtPopUserName.SetText(s.GetText());
     grdEmployee.PerformCallback('bind;'+hfTrans.Get(key));
      popUser.Show();
  }
  function OnSelectEmployeeDone() {

      grdEmployee.GetSelectedFieldValues('UserID;Name', OnGetValues);


      
  }
  function OnGetValues(results) {
          if (results.length == 0)
              return;
          var value = '';
          var names = '';
          for (i = 0; i < results.length; i++) {
              value += results[i][0] + ';';
              names += results[i][1] + ', ';
          }
          hfTrans.Set(key, value);
        //  lbUserId.SetText(value);
          txtctr.SetText(names);
         popUser.Hide();
     }
     function onFileChanged(s, e) {
         if (s.GetText() != 'Cancel') {
             s.SetText('Cancel');
             toggleUpload('change');
         }
         else {
             //s.SetText('Change File');
             clbCancel.PerformCallback();
         }
     }
     function toggleUpload(s) {
         var text = s;
         switch (text) {
             case 'change':
                 //var dv = document.getElementById('divReadDoc');
                 //dv.style.display = 'none';
                 upcDoc.SetClientVisible(true);
                 break;
             case 'view':
                 //var dv = document.getElementById('divReadDoc');
                 //dv.style.display = 'block';
                 upcDoc.SetClientVisible(false);


                 break;


         }
     }
     function OnUploadCanceled(e) {
         btnChange.SetText(e.result);
         toggleUpload('view');
     }
   </script>
</head>
<body>
    <form id="form1" runat="server" style="width: 1000px">
    <div>
        <table width="100%">
            <tr>
                <td valign="top" width="25%" style="height:150px">

                    <dx:ASPxRoundPanel ID="pnlFax" runat="server" Width="100%" HeaderText="Fax Properties"
                        View="GroupBox" Height="100%">
                        <PanelCollection>
                            <dx:PanelContent ID="Pane2" runat="server" SupportsDisabledAttribute="True">
                            <table width="100%" style="height:145px">
                         
                            <tr><td width="60px" valign="middle">Subject</td>
                                <td colspan="3" valign="middle" 
                                    bgcolor="#CCCCCC"> <dx:ASPxTextBox ID="txtSubject" runat="server" Width="100%" 
                                                ClientInstanceName="txtSubject">
                                            </dx:ASPxTextBox></td></tr>
                                 <tr><td valign="middle">Received Date</td><td valign="middle" bgcolor="#CCCCCC">
                                     <dx:ASPxDateEdit ID="dteReceivedDate" runat="server" 
                                         ClientInstanceName="dteReceivedDate" EditFormat="Custom" 
                                         EditFormatString="dd MMM yyyy hh:mm tt" UseMaskBehavior="True">
                                     </dx:ASPxDateEdit>
                                     </td><td valign="middle"></td><td valign="middle">
                                     </td></tr>
                                <tr>
                                    <td valign="middle">
                                        Inbox</td>
                                    <td valign="middle" bgcolor="#CCCCCC">
                                        <dx:ASPxComboBox ID="cboInbox" runat="server" DataSourceID="xpodsInbox" 
                                            TextField="Name" ValueField="Name">
                                        </dx:ASPxComboBox>
                                    </td>
                                    <td valign="middle">
                                        From</td>
                                    <td valign="middle" bgcolor="#CCCCCC">
                                        <dx:ASPxComboBox ID="cboContact" runat="server" DataSourceID="xpodsContactFrom" 
                                            DropDownRows="5" DropDownStyle="DropDown" IncrementalFilteringMode="Contains" 
                                            TextField="Name" ValueField="ID">
                                        </dx:ASPxComboBox>
                                    </td>
                                </tr>
                                <tr>
                                    <td height="27px" valign="middle">
                                        Remarks</td>
                                    <td colspan="3" height="27px" valign="middle" bgcolor="#CCCCCC">
                                        <dx:ASPxTextBox ID="txtRemarks" runat="server" Width="100%">
                                        </dx:ASPxTextBox>
                                        </td>
                                    
                                </tr>
                            </table>
                         
                            </dx:PanelContent>
                        </PanelCollection>
                    </dx:ASPxRoundPanel>
                </td>
                <td valign="top"  style="height:150px">
                    <dx:ASPxRoundPanel ID="pnlDistr" runat="server" HeaderText="Distribution"
                        View="GroupBox" Width="100%" Height="100%">
                        <PanelCollection>
                            <dx:PanelContent ID="PanelContent3" runat="server" SupportsDisabledAttribute="True">
                               
                                <table width="100%" style="height:145px">
                                 <tr>
                                    <td width="88px">Log No.</td>
                                        <td bgcolor="#CCCCCC">
                                            <dx:ASPxLabel ID="lblNo" runat="server" Text="(auto generated)">
                                            </dx:ASPxLabel>
                                            
                                        </td>
                                    </tr>
                                <tr>
                                <td>Attn</td>
                                <td bgcolor="#CCCCCC">
                                    <dx:ASPxButtonEdit ID="bteAttn" runat="server" ClientInstanceName="bteAttn" 
                                        Width="100%">
                                        <ClientSideEvents ButtonClick="function(s, e) {
ShowSelectEmployee(s,&quot;attn&quot;);
}" />

                                        <Buttons>
                                            <dx:EditButton>
                                            </dx:EditButton>
                                        </Buttons>
                                    </dx:ASPxButtonEdit>
                                    </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            Cc</td>
                                        <td bgcolor="#CCCCCC">
                                            <dx:ASPxButtonEdit ID="bteCc" runat="server" Width="100%" 
                                                ClientInstanceName="bteCc">
                                                <ClientSideEvents ButtonClick="function(s, e) {
	ShowSelectEmployee(s,&quot;cc&quot;);
}" />


                                                <Buttons>
                                                    <dx:EditButton>
                                                    </dx:EditButton>
                                                </Buttons>
                                            </dx:ASPxButtonEdit>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            File</td>
                                        <td bgcolor="#CCCCCC">
                                            <dx:ASPxButton ID="btnChange" runat="server" AutoPostBack="False" 
                                                ClientInstanceName="btnChange" Width="280px">
                                                <ClientSideEvents Click="function(s, e) {
	onFileChanged(s,e);
}" />
                                            </dx:ASPxButton>
                                            <dx:ASPxUploadControl ID="upcDoc" runat="server" ClientInstanceName="upcDoc" 
                                                Width="280px" ClientVisible="False" 
                                                OnFileUploadComplete="upcDoc_FileUploadComplete" ShowUploadButton="True">
                                                <ValidationSettings AllowedFileExtensions="pdf, msg, eml" MultiSelectionErrorText="Attention! 

The following {0} files are invalid because they exceed the allowed file size ({1}) or their extensions are not allowed. These files have been removed from selection, so they will not be uploaded. 

{2}" MaxFileSize="30000000">
                                                </ValidationSettings>
                                                <ClientSideEvents FilesUploadComplete="function(s, e) {
	alert('hel');
}" FileUploadComplete="function(s, e) {
	 Distribute();
}" TextChanged="function(s, e) {
	
}" />
                                            </dx:ASPxUploadControl>
                                        </td>
                                    </tr>
                                </table>
                            </dx:PanelContent>
                        </PanelCollection>
                    </dx:ASPxRoundPanel>
                </td>
            </tr>
            <tr>
                <td style="width: 50%" valign="top">

                    &nbsp;</td>
                <td width="100%" align="right" valign="top">
                   <table><tr><td><dx:ASPxButton ID="btnDistribute" runat="server" Text="Send" 
                                                ClientInstanceName="btnDistribute" 
                           OnClick="btnDistribute_Click" UseSubmitBehavior="False">
<ClientSideEvents Click="function(s, e) {
	ShowLoading('Please wait...');
}"></ClientSideEvents>
                                            </dx:ASPxButton></td><td> 
                       <dx:ASPxButton ID="btnSave" runat="server" Text="Save" 
                           ClientInstanceName="btnSave" onclick="btnSave_Click">
                           <ClientSideEvents Click="function(s, e) {
	ShowLoading('Please wait..');
}" />
                       </dx:ASPxButton>
                   </td></tr></table></td>
            </tr>
        </table>
        
    </div>
    <dx:XpoDataSource ID="xpoDsContactTo" runat="server" 
        Criteria="[Contact.Internal] = True" 
        TypeName="POI.eTransmittal.Enitity.ContactInfo">
    </dx:XpoDataSource>

                                            <dx:XpoDataSource runat="server" 
        ID="xpodsContactFrom" Criteria="[Internal] &lt;&gt; True" 
        TypeName="POI.eTransmittal.Enitity.Contact"></dx:XpoDataSource>

                                            <dx:ASPxCallback runat="server" 
        ID="clbOperation" OnCallback="clbOperation_Callback" 
        ClientInstanceName="clbOperation">
                                                <ClientSideEvents CallbackComplete="function(s, e) {
	
		window.close();
}" />
    </dx:ASPxCallback>

                                        <dx:ASPxHiddenField ID="hfTrans" 
        runat="server" ClientInstanceName="hfTrans">
    </dx:ASPxHiddenField>

                                        <dx:ASPxLabel ID="lblCc" runat="server" 
        ClientInstanceName="lblCc" ClientVisible="False" Text="lblCc">
    </dx:ASPxLabel>
    <dx:ASPxLabel ID="lblAttn" runat="server" ClientInstanceName="lblAttn" 
        ClientVisible="False" Text="lbl">
    </dx:ASPxLabel>

                                        <dx:XpoDataSource ID="xpodsInbox" 
        runat="server" TypeName="POI.eTransmittal.Enitity.Inbox">
    </dx:XpoDataSource>

                                        <dx:XpoDataSource ID="xpoDsFaxFrom" 
        runat="server" TypeName="POI.eTransmittal.Enitity.ContactInfo" 
        Criteria="[Contact.ID] = ?">
                                            <CriteriaParameters>
                                                <asp:SessionParameter DefaultValue="-99" Name="Contact.ID" 
                                                    SessionField="poi.eTransmittal_ContactsDetail" />
                                            </CriteriaParameters>
    </dx:XpoDataSource>

                                        <dx:ASPxCallback ID="clbCancel" 
        runat="server" ClientInstanceName="clbCancel" oncallback="clbCancel_Callback">
                                            <ClientSideEvents CallbackComplete="function(s, e) {
	OnUploadCanceled(e);
}" />
    </dx:ASPxCallback>

                                        <dx:XpoDataSource ID="xpodstransUser" 
        runat="server" TypeName="POI.eTransmittal.Enitity.TransmittalUser">
    </dx:XpoDataSource>

                                        <dx:ASPxPopupControl ID="popInfo" 
        runat="server" HeaderText="Information" Modal="True" Width="500px" 
        PopupHorizontalAlign="WindowCenter" PopupVerticalAlign="WindowCenter" 
        style="margin-right: 0px" ClientInstanceName="popInfo">
                                            <ContentCollection>
<dx:PopupControlContentControl runat="server" SupportsDisabledAttribute="True">
<table width="100%"><tr><td> <dx:ASPxLabel ID="lblInfoMessage" runat="server" 
        EncodeHtml="False" Width="100%" Wrap="True" Height="100px">
    </dx:ASPxLabel></td></tr><tr><td align="right"><table><tr><td>
        <dx:ASPxButton ID="btnErrorOk" runat="server" AutoPostBack="False" 
            ClientInstanceName="btnErrorOk" Text="Ok" Visible="False">
            <ClientSideEvents Click="function(s, e) {
	popInfo.Hide()
}" />
        </dx:ASPxButton>
        <dx:ASPxButton ID="btnInfoOk" runat="server" Text="Ok " AutoPostBack="False" 
            Width="76px" Visible="False">
            <ClientSideEvents Click="function(s, e) {
popInfo.Hide();
	clbOperation.PerformCallback('isredirect');

}" />
    </dx:ASPxButton></td></tr></table></td></tr></table>
    
                                                </dx:PopupControlContentControl>
</ContentCollection>
    </dx:ASPxPopupControl>

                                        <dx:ASPxPopupControl ID="popUser" 
        runat="server" HeaderText="Select User" Width="500px" 
        PopupHorizontalAlign="WindowCenter" PopupVerticalAlign="TopSides" 
        Modal="True">
                                            <ContentCollection>
<dx:PopupControlContentControl runat="server" SupportsDisabledAttribute="True">
<table width="100%"><tr><td>
    <dx:ASPxGridView ID="grdEmployee" runat="server" AutoGenerateColumns="False" 
        Width="100%" ClientInstanceName="grdEmployee" 
        OnCustomCallback="grdEmployee_CustomCallback" Font-Size="X-Small" 
        DataSourceID="xpodstransUser" KeyFieldName="UserID">
        <Columns>
            <dx:GridViewCommandColumn Caption=" " ShowInCustomizationForm="True" 
                VisibleIndex="0" ShowSelectCheckbox="True" Width="25px">
            </dx:GridViewCommandColumn>
            <dx:GridViewDataTextColumn FieldName="UserID" ShowInCustomizationForm="True" 
                VisibleIndex="1" Caption="ID">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn FieldName="Name" ShowInCustomizationForm="True" 
                VisibleIndex="2">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn FieldName="Email" ShowInCustomizationForm="True" 
                Visible="False" VisibleIndex="3">
            </dx:GridViewDataTextColumn>
        </Columns>
        <SettingsPager PageSize="5">
        </SettingsPager>
        <Settings ShowFilterRow="True" />
    </dx:ASPxGridView></td><td width="80px" valign="top"><table width="100%"<tr></tr>
      
            <tr>
                <td>
                    
                    <dx:ASPxButton ID="btnuserSave" runat="server" AutoPostBack="False" Text="Ok" 
                        Width="75px">
                        <ClientSideEvents Click="function(s, e) {
	OnSelectEmployeeDone();
}" />
                    </dx:ASPxButton>
                    
                </td>
                <tr>
                    <td>
                       <dx:ASPxButton ID="btnuserCancel" runat="server" Text="cancel" 
                                        AutoPostBack="False" Width="75px">
                                        <ClientSideEvents  Click="function(s, e) {
	popUser.Hide();

}" />
                                    </dx:ASPxButton>
                    </td>
                </tr>
            </tr>
     
    </table></td></tr></table>
  
    
    
                                                </dx:PopupControlContentControl>
</ContentCollection>
    </dx:ASPxPopupControl>
    <uc1:StatusControl ID="stControl" runat="server" />
    </form>
</body>
</html>
